<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2020/4/23
 * Time: 9:40
 */

namespace Modules\Api\Http\Controllers;

use HiCommon\Repository\RoadRescueOrderRepository;
use Illuminate\Support\Facades\Request;
use Modules\Api\Service\RoadRescueService;
class RoadRescueController extends BaseController
{

    /**
     *  获取道路救援原因列表
     *  hinq 2020 4 27
     *
     **/
    public function road_rescue_refund_list(){
        $arr_list = RoadRescueService::refund_list();
        return hello_success('ok', $arr_list );
    }


    /**
     *  获取道路救援列表
     *  hinq 2020 4 23
     *
     **/
    public function road_rescue_list(){
        $arr_list = road_rescue_server_type();
        return hello_success('ok' , $arr_list);
    }


    /**
     *  获取道路救援机构列表
     *  hinq 2020 4 23
     *
     **/
    public function road_rescue_shop( Request $request ){
        $arr_input = (array) $request::all();
        return RoadRescueService::road_rescue_shop( (array) $arr_input );
    }


    /**
     *  生成订单信息
     *  hinq 2020 4 23
     *
     **/
    public function road_rescue_order( Request $request ){
        $arr_input = (array) $request::all();
        return RoadRescueService::road_rescue_order( (array) $arr_input );
    }


    /**
     *  根据参数重新获取价格
     *  hinq 2020 4 25
     *
     **/
    public function road_rescue_get_price( Request $request ){
        $arr_input = (array) $request::all();
        return RoadRescueService::road_rescue_get_price( (array) $arr_input );
    }


    /**
     *  支付订单信息
     *  hinq 2020 4 24
     *
     **/
    public function pay_order( Request $request ){
        $arr_input = (array) $request::all();
        shiwu_start();
        $result = RoadRescueService::pay_order( (array) $arr_input );
        shiwu_end($result);
        return  $result;
    }



    /**
     *  获取当前用户订单
     *  hinq 2020 4 24
     *
     **/
    public function road_rescue_get_order( Request $request )
    {
        return RoadRescueService::road_rescue_get_order();
    }


    /**
     *  申请退款流程
     *  hinq 2020 4 27
     *
     **/
    public function road_rescue_refund( Request $request ){
        $arr_input = (array) $request::all();
        return RoadRescueService::road_rescue_refund( (array) $arr_input );
    }

    /**
     *  实时获取当前订单状态
     *  hinq 2020 5 15
     *
     **/
    public function check_order_status( Request $request  ){
        $arr_input = (array) $request::all();
        return RoadRescueService::check_order_status( (array) $arr_input );
    }


    /**
     *  获取指定id的订单信息
     *  hinq 2020 4 28
     *
     **/
    public function order_detail( Request $request ){
        $n_id = (int) $request::get('id');
        return RoadRescueService::get_order_detail( (int) $n_id );
    }


    /**
     *  取消指定订单
     *  hinq 2020 4 28
     *
     **/
    public function delete( Request $request ){
        $n_id = (int) $request::get( 'id' );
        return RoadRescueService::delete( (int) $n_id );
    }

    /**
     *  删除指定的订单
     *  hinq 2020 5 6
     *
     **/
    public function order_del( Request $request ){
        $n_id = (int) $request::get( 'id' );
        return RoadRescueService::order_del( (int) $n_id );
    }


    /**
     *  完成指定订单
     *  hinq 2020 4 28
     *
     **/
    public function accomplish( Request $request ){
        $n_id = (int) $request::get( 'id' );
        return RoadRescueService::accomplish( (int) $n_id );
    }

    /**
     *  获取用户的订单列表
     *  hinq 2020 4 28
     *
     **/
    public function order_list( Request $request ){
        $arr_search = (array) $request::all();
        return RoadRescueService::order_list( (array) $arr_search );
    }


    /**
     *  获取道路救援服务协议
     *  hinq 2020 5 6
     *
     **/
    public function protocol(){
        return RoadRescueService::protocol();
    }


    /**
     *  申请退款 商家1小时后未处理  系统自动退款
     *  hinq 2020 6 1
     *
     **/
    public function order_auth_refund(){
        return RoadRescueService::order_auth_refund();
    }


    public function order_auth_apprise(){
//        //优化  订单主动评价的时候将订单做一个已评价的标示
//        //手动完成的时候 记录完成时间   refund_time_success字段记录
//        //获取所有正在申请退款的订单
//        $where = ['status'=>3];
//        $arr_option['with'] = ['user_apprise'];
//        $arr_option['field'] = ['id'];
//        $arr_list = \HiCommon\Repository\RoadRescueOrderRepository::get_all2( (array) $where , (array) $arr_option )->toarray();
//        if( empty( $arr_list) ){
//            return hello_success('ok',[]);
//        }
    }



}